//
//  BaseNetwork.h
//  PaiLeXiongProject
//
//  Created by 小獾科技 on 2017/8/16.
//  Copyright © 2017年 小獾科技. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "AFNetworking.h"

typedef NS_ENUM(NSInteger, InterfaceType)
{
    InterfaceTypeDefault,
    InterfaceTypeLong,
    InterfaceTypeAD
};

typedef void(^CompleteObjBlock)(id obj); // obj:model/dict等
typedef void(^CompleteArrayVlock)(NSArray *array);
typedef void(^CompleteVoidBlock)(void);
typedef void(^FailedBlock)(NSString *message);
typedef void(^ProgressBlock)(float progress);

// 第一个参数是服务器端返回的结果， 第二个参数是错误信息（针对服务器端返回的状态码错误，非JSON数据信息）
typedef void(^CompletionBlock)(NSDictionary *resultDict);
typedef void(^FailureBlock)(NSError *error, NSString *errorMsg);

@interface BaseNetwork : NSObject

@property (nonatomic, strong) AFHTTPSessionManager *httpSessionManager;

@property (nonatomic, assign) BOOL enableCache;//是否需要缓存数据，默认开启缓存

@property (nonatomic, assign) InterfaceType interfaceType;//接口类型

@property (nonatomic, assign) BOOL needRetry;// 默认YES，上传接口不需要，手动设置为NO


/***
 * GET请求的常用方式
 */
- (void)sendGetRequestURL:(NSString *)urlString parameters:(NSDictionary *)parameters completionBlockWithSuccess:(CompletionBlock)completionBlock andFailure:(FailureBlock)failure;

/***
 * POST请求--基本需求，发送只有参数的方式
 */
- (void)sendPostRequestURL:(NSString *)urlString parameters:(NSDictionary *)parameters completionBlockWithSuccess:(CompletionBlock)completionBlock andFailure:(FailureBlock)failure;

/***
 * 上传图片
 */
- (void)uploadImageRequestURL:(NSString *)urlString imageArray:(NSArray *)imageArray parameters:(NSDictionary *)parameters progress:(ProgressBlock)progress completionBlockWithSuccess:(CompletionBlock)completionBlock andFailure:(FailureBlock)failure;

- (NSString *)handleUrlStr:(NSString *)urlString withDict:(NSDictionary *)dict;


@end
